package SceneUnit
{
	import BasicEngine.*;
	import BasicEngine.Dispatcher;
	import BasicEngine.MsgId;
	import BasicEngine.MsgManager;
	import DataStore.ResourceManager;
	
	import DataStore.DataSource;
	
	import Player.BaseProc;

	public class SceneProc  
	{
		private static  var loadInterval:int = 40;
		private static var loadIntervalCounter:int;
		public function SceneProc()
		{
		}
		
		public  static function Update(_msg:MsgId):void
		{
			for (var i:int = 102; i < 140; i++)
			{
				//MsgManager.SendMessage(new MsgId("个体循环消息", 0, i, DataSource.MsgMins["Update"], null));		
			}
			UpdateLoadTask();
		}		
		
		public static function KeyDown(_msg:MsgId):void
		{
			var keyCode:uint = uint(_msg.Data);
			var key:String = DataSource.GetKey(keyCode);
			KeyMouseManager.KeyDowns[keyCode] = true;
			if (SceneManager.CurrentId != -1)
			{			
			   MsgManager.SendMessage(new MsgId("", 0, SceneManager.CurrentId, DataSource.MsgMins["KeyDown"], keyCode));
			}
		}
		
		public static function KeyUp(_msg:MsgId):void
		{
			var keyCode:uint = uint(_msg.Data);
			var key:String = DataSource.GetKey(keyCode);
			KeyMouseManager.KeyDowns[keyCode] = false;
			if (SceneManager.CurrentId != -1)
			{			
			   MsgManager.SendMessage(new MsgId("", 0, SceneManager.CurrentId, DataSource.MsgMins["KeyUp"], keyCode));
			}
		}
		
		private static function UpdateLoadTask():void
		{
			if (loadIntervalCounter > loadInterval)
			{
				ResourceManager.ExecuteLoadTask();
				loadIntervalCounter = 0;
			}
			else
			{
				loadIntervalCounter += Dispatcher.Clock.Tick;
			}
		}
	}
}